<template>
    <div class="content">
      <div class="login">
        <h1>用户注册</h1>
        <div style="margin-top: 25px;"></div>
        <el-form ref="loginForm" label-width="100px" :model="rule" style="max-width: 460px">
          <el-form-item label="用户名:">
            <el-input v-model="rule.UserName" placeholder="请输入用户名" />
          </el-form-item>
          <el-form-item label="密码:">
            <el-input v-model="rule.UserPassword" type="password" placeholder="请输入密码" show-password />
          </el-form-item>
          <el-form-item label="邮箱:">
            <el-input v-model="rule.UserEmail" placeholder="请输入邮箱" />
          </el-form-item>
          <div style="margin-top: 25px;"></div>
        </el-form>
        <el-button id="zc" type="primary" @click="zhuce">注册</el-button>
        <a href="/" class="dl">登录</a>
      </div>
    </div>
  </template>
  
  <script>
  import { ref} from "vue";
  import axios from 'axios';
  import { useRouter } from 'vue-router'
  import { ElMessage } from 'element-plus'
  export default{
    setup(){ 
    const router = useRouter();
    const rule = ref({
         userId:0,
         userCreateTime: new Date(),
         UserEmail: "",
         userIdentity: 0,
         userImg: "123",
         UserName: "",
         UserPassword: "",
         userState: 0,
         userTelephone: "1231231231321"
    });
    function zhuce (){
         axios.post("/api/api//Login",rule.value)
        .then((response)=>{
            console.log(rule.value)
            if(response.data ===1){
            ElMessage.success("注册成功");
            router.push({path:"/"})
            }else{
            ElMessage.error('注册失败')
         }
        })
        };
        return {
            rule,
            zhuce,
        };
    }
  }
</script>
<style>
.dl{
    color: white;
    margin-left: 5px;
}
h1{
color: #5C5F62;
font-size: 40px;
}
* {
    margin: 0px;
    padding: 0px;
}
#zc{
    width: 290px;
    height: 40px;
    margin-left: 120px;
}
#cz{
    width: 150px;
    margin-left: 18px;
    height: 40px;
}
.content {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/* 毛边效果 */
.login {
  margin-top: 250px;
  width: 500px;
  height: 330px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  padding: 20px;
  backdrop-filter: blur(10px);
}

.login>h1 {
    text-align: center;
}

.login el-form-item {
  margin-bottom: 20px;
}
.content {
  width: 100%;
  height: 100vh;
  background-image: url('../assets/黑海.jpg');
  background-size: cover;
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>
